import requests
import random
from threading import Thread


def stock_func():
    url1 = 'http://127.0.0.1:8000/v1/stock'
    url2 = 'http://127.0.0.1:8001/v1/stock'
    url = random.choice([url1,url2])

    html = requests.get(url=url).json()
    print(html)


#创建30个线程
li = []
for i in range(30):
    t = Thread(target=stock_func)
    li.append(t)
    t.start()
    # t.join()

for t in li:
    t.join()